﻿using UnityEngine;
using System.Collections;

public class LineMood : MonoBehaviour
{
    public GameObject start;
    public GameObject end;

    public bool right = true;
    private float speed = 1f;
    
	void Start()
    {
        transform.position = end.transform.position;
	}
	
	void Update()
    {
        float step = speed * Time.deltaTime;

        if (transform.position == end.transform.position)
        {
            right = false;
        }
        else if (transform.position == start.transform.position)
        {
            right = true;
        }

        if (right)
        {
            transform.position = Vector3.MoveTowards(transform.position, end.transform.position, step);
        }
        else
        {
            transform.position = Vector3.MoveTowards(transform.position, start.transform.position, step);
        }
    }


}
